home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / w3 / w3-print.el.z / w3-print.el
Encoding:
Text File  |  1998-05-21  |  3.0 KB  |  85 lines

  1. ;;; w3-print.el --- Printing support for emacs-w3
  2. ;; Author: wmperry
  3. ;; Created: 1997/10/17 14:08:20
  4. ;; Version: 1.10
  5. ;; Keywords: faces, help, printing, hypermedia
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;;; Copyright (c) 1993 - 1996 by William M. Perry <wmperry@cs.indiana.edu>
  9. ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
  10. ;;;
  11. ;;; This file is part of GNU Emacs.
  12. ;;;
  13. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  14. ;;; it under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 2, or (at your option)
  16. ;;; any later version.
  17. ;;;
  18. ;;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
  25. ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26. ;;; Boston, MA 02111-1307, USA.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28. (defvar w3-postscript-print-function 'ps-print-buffer-with-faces
  29.   "*Name of the function to use to print a buffer as PostScript.
  30. This should take no arguments, and act on the current buffer.
  31. Possible values include:
  32. ps-print-buffer-with-faces   - print immediately
  33. ps-spool-buffer-with-faces   - spool for later")
  34.  
  35. ;;;###autoload
  36. (defun w3-print-this-url (&optional url format)
  37.   "Print out the current document (in LaTeX format)"
  38.   (interactive)
  39.   (if (not url) (setq url (url-view-url t)))
  40.   (let* ((completion-ignore-case t)
  41.      (format (or format
  42.              (completing-read
  43.               "Format: "
  44.               '(("HTML Source")        ; The raw HTML code
  45.             ("Formatted Text")     ; Plain ASCII rendition
  46.             ("PostScript")        ; Pretty PostScript
  47.             ("LaTeX'd")        ; LaTeX it, then print
  48.             )
  49.               nil t))))
  50.     (save-excursion
  51.       (cond
  52.        ((equal "HTML Source" format)
  53.     (if w3-current-source
  54.         (let ((x w3-current-source))
  55.           (set-buffer (get-buffer-create url-working-buffer))
  56.           (erase-buffer)
  57.           (insert x))
  58.       (url-retrieve url))
  59.     (lpr-buffer))
  60.        ((or (equal "Formatted Text" format)
  61.         (equal "" format))
  62.     (lpr-buffer))
  63.        ((equal "PostScript" format)
  64.     (funcall w3-postscript-print-function))
  65.        ((equal "LaTeX'd" format)
  66.      (w3-parse-tree-to-latex w3-current-parse url)
  67.     (save-window-excursion
  68.       (write-region (point-min) (point-max)
  69.             (expand-file-name "w3-tmp.latex"
  70.                       w3-temporary-directory) nil 5)
  71.       (shell-command
  72.        (format
  73.         "cd %s ; latex w3-tmp.latex ; latex w3-tmp.latex ; %s w3-tmp.dvi ; rm -f w3-tmp*"
  74.         w3-temporary-directory
  75.         w3-print-command))
  76.       (kill-buffer "*Shell Command Output*")))))))
  77.  
  78. ;;;###autoload
  79. (defun w3-print-url-under-point ()
  80.   "Print out the url under point (in LaTeX format)"
  81.   (interactive)
  82.   (w3-print-this-url (w3-view-this-url t)))
  83.  
  84. (provide 'w3-print)
  85.